home *** CD-ROM | disk | FTP | other *** search
/ The Game Master (3rd Edition) / The Game Master 3rd edition.iso / files / demo_vga / utilega2 / nansi.doc < prev    next >
Encoding:
Text File  |  1986-06-09  |  10.5 KB  |  214 lines

  1. ¢4 L                                     NANSI.SYS
  2.  
  3.                             Thu, 13 Feb 86 18:27:23 PST
  4.  
  5.                                   - Daniel Kegel
  6.                    nansi   - enhanced MS-DOS ansi console driver
  7.  
  8.          SYNOPSIS
  9.          Include in \config.sys the line
  10.                                  device=nansi.sys
  11.  
  12.          DESCRIPTION
  13.  
  14.          Nansi.sys is a console driver which understands ANSI control
  15.          sequences.  It has several advantages over ANSI.SYS (the driver
  16.          supplied with DOS):
  17.  
  18.          1. It supports new escape sequences (see below).
  19.          2. It provides MUCH faster output under certain conditions.
  20.          3. It supports the 43-line mode of the EGA.
  21.          4. The darned bell is now 1/4 second instead of 1/2 second long.
  22.  
  23.          What a console driver does:   When you, for example, type
  24.                                  C:> type foo.txt
  25.          COMMAND.COM opens the file foo.txt, reads it, and writes it to
  26.          the console driver, which puts it up on the screen.
  27.  
  28.          Both ansi.sys and nansi.sys use IBM Video BIOS to control the
  29.          screen.  However, nansi.sys bypasses BIOS if the screen is in a
  30.          text mode; this allows much faster operation under certain conditions.
  31.  
  32.          While putting text up on the screen, (n)ansi.sys keeps a lookout for
  33.          the escape character (chr(27), known as ESC); this character signals
  34.          the start of a terminal control sequence.
  35.  
  36.          Terminal control sequences follow the format
  37.                  ESC [ param; param; ...; param cmd
  38.          where
  39.                  ESC     is the escape character chr$(27).
  40.                  [       is the left bracket character.
  41.                  param   is an ASCII decimal number, or a string in quotes.
  42.                  cmd     is a case-specific letter identifying the command.
  43.  
  44.          Usually, zero, one, or two parameters are given.  If parameters
  45.          are omitted, they usually default to 1; however, some commands
  46.          (KKR and DKOCT) treat the no-parameter case specially.  Spaces are
  47.          not allowed between parameters.
  48.  
  49.          For example, both ESC[1;1H and ESC[H send the cursor to the home
  50.          position (1,1), which is the upper left.
  51.  
  52.          Either single or double quotes may be used to quote a string.
  53.          Each character inside a quoted string is equivalent to one numeric
  54.          parameter.  Quoted strings are normally used only for the Keyboard
  55.          Key Reassignment command.
  56.  
  57.          Control Sequences
  58.          The following table lists the sequences understood by nansi.sys.
  59.          Differences between nansi.sys and the standard ansi.sys are marked
  60.          with a vertical bar (|).
  61.  
  62.                ¢0t¢2 K
  63.  Cursor Positioning
  64.  Short   Long name               Format          Notes
  65.  CUP     cursor position         ESC[y;xH        Sets cursor position.
  66.  HVP     cursor position         ESC[y;xf        Same as CUP; not recommended.
  67.  CUU     cursor up               ESC[nA          n = # of lines to move
  68.  CUD     cursor down             ESC[nB
  69.  CUF     cursor forward          ESC[nC          n = # of columns to move
  70.  CUB     cursor backward         ESC[nD
  71.  DSR     Device Status, Report!  ESC[6n          Find out cursor position.
  72.  CPR     Cursor Position report  ESC[y;xR        Response to DSR, as if typed.
  73.  SCP     Save Cursor Position    ESC[s           Not nestable.
  74.  RCP     Restore Cursor Position ESC[u
  75.  
  76.  Editing
  77.  ED      Erase in Display        ESC[2J  Clears screen.
  78.  EL      Erase in Line           ESC[K   Clears to end of line.
  79.  IL  |   Insert Lines            ESC[nL  Inserts n blank lines at cursor line.
  80.  DL  |   Delete Lines            ESC[nM  Deletes n lines including cursor line.
  81.  ICH |   Insert Characters       ESC[n@  Inserts n blank chars at cursor.
  82.  DCH |   Delete Characters       ESC[nP  Deletes n chars including cursor char.
  83.  
  84.                                  NANSI.SYS  page 2
  85.  
  86.  Mode-Setting
  87.  SGR     Set Graphics Rendition  ESC[n;n;...nm   See character attribute table.
  88.  SM      Set Mode                ESC[=nh         See screen mode table.
  89.  RM      Reset Mode              ESC[=nl         See screen mode table.
  90.  IBMKKR  Keyboard Key Reass.     ESC["string"p
  91.          The first char of the string gives the key to redefine; the rest
  92.          of the string is the key's new value.
  93.          To specify unprintable chars, give the ASCII value of the char
  94.          outside of quotes, as a normal parameter.
  95.          IBM function keys are two byte strings; see the IBM Basic manual.
  96.          For instance, ESC[0;";dir a:";13;p redefines function key 1 to
  97.          have the value "dir a:" followed by the ENTER key.
  98.        | If no parameters given, all keys are reset to their default values.
  99.  
  100.  DKOCT | Output char translate   ESC[n;ny
  101.        | When first char is encountered in output request, it is replaced with
  102.        | the second char.  This might be useful for previewing text before
  103.        | sending it to a printer with a funny print wheel.
  104.        | If no parameters are given, all chars are reset to normal.
  105. ¢0u¢0 K
  106.  
  107.          Character Attributes
  108.  
  109.          The Set Graphics Rendition command is used to select foreground
  110.          and background colors or attributes.
  111.  
  112.          When you use multiple parameters, they are executed in sequence,
  113.          and the effects are cumulative.
  114.  
  115.             Attrib code          Value
  116.                  0         All attributes off (normal white on black)
  117.                  1         Bold
  118.                  4         Underline
  119.                  5         Blink
  120.                  7         Reverse Video
  121.                  8         Invisible (but why?)
  122.                  30-37     foregnd blk/red/grn/yel/blu/magenta/cyan/white
  123.                  40-47     background
  124.  
  125.          Screen Modes
  126.  
  127.          The IBM BIOS supports several video modes; the codes given in the
  128.          BIOS documentation are used as parameters to the Set Mode command.
  129.          (In bitmap modes, the cursor is simulated with a small blob (^V).)
  130.  
  131.              Mode Code           Value
  132.                  0               text 40x25 Black & White
  133.                  1               text 40x25 Color
  134.                  2               text 80x25 Black & White
  135.                  3               text 80x25 Color
  136.                  4               bitmap 320x200 4 bits/pixel
  137.                  5               bitmap 320x200 1 bit/pixel
  138.                  6               bitmap 640x200 1 bit/pixel
  139.                  7               (cursor wrap kludge)
  140.                  13 (EGA)        bitmap 320x200 4 bits/pixel ?
  141.                  14 (EGA)        bitmap 640x200 4 bits/pixel
  142.                  16 (EGA)        bitmap 640x350 4 bits/pixel
  143.          Mode 7 is an unfortunate kludge; Setting mode 7 tells the cursor
  144.          to wrap around to the next line when it passes the end of a line;
  145.          Resetting mode 7 tells the cursor to not wrap, but rather stay put.
  146.        | If your computer has the Enhanced Graphics Adaptor, modes between
  147.        | 8 and 15 are also supported; see the EGA BIOS for info.
  148.        | The EGA also lets you use a shorter character cell in text modes
  149.        | in order to squeeze 43 lines of text out of the 25-line text modes.
  150.        | To enter 43 line mode, set the desired 25-line text mode (0 to 3),
  151.        | then Set Mode 43.  For instance: ESC[=3h ESC[=43h.
  152.        | To exit 43 line mode, set the desired 25-line text mode again.
  153.        | Nansi.sys ignores mode 43 unless there is an EGA on your computer.
  154.  
  155.          Faster Output
  156.  
  157.        | Any program that sets the console to RAW mode, and buffers its
  158.        | output properly, can achieve extremely high screen update speeds in
  159.        | return for giving up the special functions of the keys ^C, ^S, and ^P.
  160.        | See IOCTL in the MS-DOS 3.x Technical Reference for more info.
  161.          Also, a small improvement in speed may be noticed with some
  162.          programs that use the DOS console in normal mode, as this driver
  163.          efficiently implements the (standard but undocumented) INT 29h
  164.          most-favored-device putchar used by DOS.
  165.  
  166.  
  167.                                  NANSI.SYS  page 3
  168.  
  169.                                      EXAMPLES
  170.          See the file setraw.doc for Macro Assembler, Lattice C,
  171.          and Microsoft C routines for entering and leaving raw mode.
  172.  
  173.                                        BUGS
  174.          Insert and delete character do not work in graphics modes.
  175.          Graphics mode writing is slow.
  176.          The simulated cursor in graphics mode slows down single-char
  177.          writes by a factor of 3; it should be disable-able.
  178.          Does not support erase-to-end-of-screen and other useful functions.
  179.  
  180.                                       Version
  181.          This version, 2.2, created February 1986.  Problems should
  182.          be reported to Daniel Kegel, 1-60 CIT, Pasadena, CA 91126
  183.          (or, after June 1986, 2648 169th Ave SE, Bellevue, Wa. 98008).
  184.          Your suggestions for improvement would be most welcome.
  185.  
  186.                                        NOTE
  187.          This program may be distributed for educational and personal use
  188.          only.  Commercial use is verboten; get in touch with the author.
  189.  
  190.                                        FILES
  191.          nansi.doc       - this file
  192.          nansi.hex       - compiled version  <Not supported by INFO-IBMPC>
  193.                  Convert nansi.hex into nansi.sys with the following commands
  194.                  (you'll end up with 256 extra bytes at end, but who cares?):
  195.                          debug                   # Run DOS debugger
  196.                          N nansi.hex             # Load the hex file
  197.                          L
  198.                          N nansi.sys             # Write it out
  199.                          W
  200.                          Q                       # Quit- back to DOS.
  201.          nansi.cat       - concatenated sources
  202.                  nansi   - makefile- shows how to assemble & link
  203.                  nansi.asm       - device driver guts
  204.                  nansi_d.asm     - definitions
  205.                  nansi_p.asm     - ANSI parameter grabber
  206.                  nansi_f.asm     - ANSI function handlers
  207.                  nansi_i.asm     - device driver init routine
  208.          setraw.cat      - concatenated examples
  209.                  setraw.asm      - for assembly programs
  210.                  setraw.msc      - for Microsoft C programs
  211.                  setraw.lc       - for Lattice C programs
  212.                  rawtest.lc      - example for Lattice C only
  213. ¢0 L
  214.